<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
    
     <div class="container-div">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>

							<li>
								货车车牌号：<input type="text" name="carNumber"/>
							</li>
							<li>
								车辆类型：
								<select name="carType" th:with="type=${@dict.getType('sys_car_type')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>
							<li>
								燃油标号：
								<select name="ranyou" th:with="type=${@dict.getType('sys_ranyou_biaohao')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>
							<li>
								汽车颜色：
								<select name="yanse" th:with="type=${@dict.getType('sys_car_yanse')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>
							<li>
								尾气排放标准：
								<select name="weiqi" th:with="type=${@dict.getType('sys_weiqi_paifang')}">
									<option value="">所有</option>
									<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
								</select>
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
				<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:carinfo:add">
					<i class="fa fa-plus"></i> 添加
				</a>
				<a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="system:carinfo:edit">
					<i class="fa fa-edit"></i> 修改
				</a>
				<a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:carinfo:remove">
					<i class="fa fa-remove"></i> 删除
				</a>
				<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:carinfo:export">
						<i class="fa fa-download"></i> 导出
				 </a>
			</div>
			<div class="col-sm-12 select-table table-striped">
				<table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
    <div th:include="include :: footer"></div>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:carinfo:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:carinfo:remove')}]];
		var carType = [[${@dict.getType('sys_car_type')}]];
		var carYanse = [[${@dict.getType('sys_car_yanse')}]];
		var carRanYou = [[${@dict.getType('sys_ranyou_biaohao')}]];
		var carWeiQi = [[${@dict.getType('sys_weiqi_paifang')}]];

        var prefix = ctx + "system/carinfo";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
				exportUrl: prefix + "/export",
                modalName: "车辆",
				search: false,
		        showExport: true,
                columns: [{
		            checkbox: true
		        },
				{
					field : 'carinfoId', 
					title : '车辆信息ID',
					visible: false
				}/*,
				{
					field : 'huiYuanId', 
					title : '会员ID',
					sortable: true
				}*/,
				{
					field : 'carNumber', 
					title : '货车车牌号',
					sortable: true
				},
				{
					field : 'carPinPai', 
					title : '车辆品牌',
					sortable: true
				},
				{
					field : 'carType', 
					title : '车辆类型',
					align: 'center',
					formatter: function(value, row, index) {
						return $.table.selectDictLabel(carType, value);
					}
				},
					{
						field : 'weiqi',
						title : '尾气排放标准',
						align: 'center',
						formatter: function(value, row, index) {
							return $.table.selectDictLabel(carWeiQi, value);
						}
					},
					{
						field : 'ranyou',
						title : '燃油标号',
						align: 'center',
						formatter: function(value, row, index) {
							return $.table.selectDictLabel(carRanYou, value);
						}
					},
					{
						field : 'yanse',
						title : '颜色',
						align: 'center',
						formatter: function(value, row, index) {
							return $.table.selectDictLabel(carYanse, value);
						}
					},
				{
					field : 'carWeight', 
					title : '载重量（吨）',
					sortable: true
				},
				{
					visible: editFlag == 'hidden' ? false : true,
					title: '车辆状态',
					align: 'center',
					formatter: function (value, row, index) {
						return statusTools(row);
					}
				},
				{
					field : 'createTime', 
					title : '创建时间',
					sortable: true
				},
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	var actions = [];
		            	actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.carinfoId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.carinfoId + '\')"><i class="fa fa-remove"></i>删除</a>');
						return actions.join('');
		            }
		        }]
            };
            $.table.init(options);
        });
		/* 车辆状态显示 */
		function statusTools(row) {
			if (row.status == 1) {
				return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.carinfoId + '\')"></i> ';
			} else {
				return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.carinfoId + '\')"></i> ';
			}
		}
		/* 车辆状态-停用 */
		function disable(carinfoId) {
			$.modal.confirm("确认要停用该车辆吗？", function() {
				$.operate.post(prefix + "/changeStatus", { "carinfoId": carinfoId, "status": 1 });
			})
		}

		/* 车辆状态-启用 */
		function enable(carinfoId) {
			$.modal.confirm("确认要启用该车辆吗？", function() {
				$.operate.post(prefix + "/changeStatus", { "carinfoId": carinfoId, "status": 0 });
			})
		}
    </script>
</body>
</html>